package com.zjj.spring.javaconfig;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import com.zjj.spring.javaconfig.config.dto.Bar;
import com.zjj.spring.javaconfig.config.dto.Foo;
import com.zjj.spring.javaconfig.config.scan.ScanTwo;
import com.zjj.spring.javaconfig.config.scan.test.ScanOne;

public class SpringConifgApplication {

	public static void main(String[] args) {
		
		ApplicationContext context = new AnnotationConfigApplicationContext("com.zjj.spring.javaconfig.config");
		
		System.out.println("******************************aware test******************************");
		//SimpleConfiguration
		String string = (String) context.getBean("simpleString");
		System.out.println(string);
		
		System.out.println("******************************singleton******************************");
		
		Foo foo1  =  (Foo) context.getBean("foo");
		Foo foo2  =  (Foo) context.getBean("foo");
		System.out.println(foo1);
		System.out.println(foo2);
		System.out.println("foo1 == foo2 :  " + ( foo1 == foo2) );
		
		System.out.println("******************************prototype******************************");
		Bar bar1  =  (Bar) context.getBean("bar");
		Bar bar2  =  (Bar) context.getBean("bar");
		System.out.println(bar1);
		System.out.println(bar2);
		System.out.println("bar1 == bar2 :  " + ( bar1 == bar2 ) );
		
		System.out.println("************************************************************");
		
		ScanOne scanOne = context.getBean(ScanOne.class);
		System.out.println(scanOne);
		ScanTwo scanTwo = context.getBean(ScanTwo.class);
		System.out.println(scanTwo);
		
		System.out.println("************************************************************");
	}
	
}
